﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

namespace MINERP.LeaderOperate.Controller
{
    class ControlBase
    {
        protected GridControl _view = null;

        [DllImport("shell32.dll ")]
        private static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);


        /// <summary>
        /// 画出行号
        /// </summary>
        /// <param name="e"></param>

        #region //helper function
        /// <summary>
        /// 用浏览器打开图片
        /// </summary>
        /// <param name="fullName"></param>
        internal void OpenFilePic(string fullName)
        {
            ShellExecute(IntPtr.Zero, new StringBuilder("open"), new StringBuilder("explorer.exe"), new StringBuilder(fullName), new StringBuilder(string.Empty), 1);
        }

        /// <summary>
        /// 设置Grid的背景色
        /// </summary>
        /// <param name="e"></param>
        internal void SetBackColor(RowStyleEventArgs e)
        {
            if (e.RowHandle % 2 == 1)
            {
                e.Appearance.BackColor = Color.LightCyan;
                e.Appearance.BackColor2 = Color.Gold;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        internal void SetPathBackColor(RowCellStyleEventArgs e)
        {
            if (e.Column.FieldName == "orderpath")
            {
                if (e.CellValue != null)
                {
                    e.Appearance.BackColor = Color.Chocolate;
                    e.Appearance.BackColor2 = Color.BlueViolet;
                }
            }
        }

        #endregion


    }
}
